This application claims priority to Japanese Patent Application No. 2001-127194 filed Apr. 25, 2001, which application is herein expressly incorporated by reference.
The present invention relates to a buzzer-driving apparatus. More particularly, the present invention provides an alarm when the driver has forgotten to remove a key from a vehicle keyhole or turn out a light. An alarm sounds if the key is left, or the light is on.
Some vehicles sound an alarm to inform the driver that the driver has forgotten to remove the key from the keyhole or turn out a light. The alarm is in the buzzer-driving apparatus.
A prior art buzzer-driving apparatus is shown in FIG. 7. In FIG. 7, reference numeral 51 denotes a microcomputer. Reference symbol P denotes a general-purpose output port of the microcomputer 51. Reference numeral 52 denotes a transistor; 53 a buzzer; 54 a sound pressure adjustment resistance; 55 a base protection resistance of the transistor 52; and 56 a level-fixing resistance of the transistor 52. A battery is connected to a terminal of the sound pressure adjustment resistance 54. The battery is disposed at the side opposite to the side at which the buzzer 53 is connected to the sound pressure adjustment resistance 54.
The buzzer 53 contains a coil. The microcomputer 51 outputs a signal to turn the transistor 52 on and off at constant periods of f0 from the general-purpose output port P. The transistor 52 is turned on and electric current flows through the coil. An iron core, disposed at the center of the coil, is magnetized and attracts a diaphragm disposed above the iron core when the transistor 52 is on. When the transistor 52 is turned off, electric current does not flow through the coil. As this occurs, the diaphragm is repelled from the core. As this operation is repeated, the diaphragm vibrates at a constant frequency. A buzzer gives a big sound due to the resonant effect of the buzzer case.
In the above-described conventional buzzer-driving apparatus, during a timer interruption, pulse signals are generated by software flowchart shown in FIG. 8. The software starts every periodical timer interruption. Initially, it is determined whether communication processing of wait is executed (step S11). If yes, processing corresponding to the communication processing of wait is executed (step S12).
Next, it is determined whether switch input of wait has been executed (step S13). If yes, processing corresponding to the switch input is executed (step S14). When all the processing of wait has finished, the level of an output of the general-purpose output port P is determined (step S15). That is, if the level of the output of the general-purpose output port P is High (high-level potential), its output is set to Low (low-level potential) (step S16). If the level of the output of the general-purpose output port P is Low (low-level potential), its output is set to High (high-level potential) (step S17).
As described above, the communication processing of wait and the processing based on the input of wait are executed before cutting the switching of the output of the general-purpose output port P. Thus, when the processing for the interruption takes a long time, the processing time of the software is delayed. As a result, a buzzer-driving frequency deviates slightly.
For example, as shown in FIG. 9, at {circle around (2)}, no delay occurs because the communication processing of wait and the processing based on the input of wait are not executed. But in {circle around (1)}, delay occurs because of the communication processing of wait and the processing based on the input of wait. In {circle around (3)}, delay occurs because of the communication processing of wait.
The deviation of the oscillation frequency poses a problem. A slight change in the frequency (buzzer-driving frequency) causes a resonant disk of the buzzer to be attracted and repelled out of sync. Therefore, the tone quality and musical interval of the buzzer are unstable. This generates a distorted buzzer sound.
The present invention overcomes the above-described problem. Accordingly, it is an object of the present invention to provide a high-quality buzzer-driving apparatus. The apparatus enables the tone quality and musical interval of a buzzer to be stable because of a stable supply of a pulse signal having a buzzer-driving frequency.
To achieve the object, in a first embodiment of the invention, a buzzer-driving apparatus is provided to drive a buzzer by using a signal generated by a microcomputer. The microcomputer includes a free running timer counting a clock of the microcomputer, a register storing a value set thereto; and an output port to output a signal generated based on the value.
When the value is set in the register, an output is set to a low-level potential at the output port and a value counted by the free running timer is reset. When the value counted by the free running timer is equal to the value, the output of the output port is inverted and the value counted by the free running timer is reset. Thus, comparing the value counted by the free running timer with the value is repeated. A signal is outputted to the output port to drive the buzzer.
In the first embodiment, the signal driving the buzzer is generated by using the free running timer of the microcomputer. Accordingly, the signal is generated without being affected by software processing of the microcomputer.
In a second embodiment, a buzzer-driving apparatus is provided to drive a buzzer by using a signal generated by a microcomputer. The microcomputer includes a free running timer counting a clock of the microcomputer; a register storing first and second values set thereto; and an output port to output a generated signal generated based on the first and second values.
When the values are set in the register, an output is set to a high-level potential of the output port and a value counted by the free running timer is reset. When the value counted by the free running timer is equal to the first value, the output of the output port is set to a low-level potential. When the value counted by the free running timer is equal to the second value, the output of the output port is set to a high-level potential and the value counted by the free running timer is reset. Thus, comparing the value counted by the free running timer with the first and second values is repeated, and a signal is outputted to the output port to drive the buzzer.
In the second embodiment, the signal driving the buzzer is generated by using the free running timer of the microcomputer. Accordingly, the signal is generated without being influenced by the software processing of the microcomputer.
According to a third embodiment, in addition to the construction of the first or second embodiments, a separate excitation type buzzer is driven.
In the third embodiment, the separate excitation type buzzer is driven by the signal having a frequency generated by the free running timer of the microcomputer.
Further areas of applicability of the present invention will become apparent from the detailed description provided hereinafter. It should be understood that the detailed description and specific examples, while indicating the preferred embodiment of the invention, are intended for purposes of illustration only and are not intended to limit the scope of the invention.